package com.example.service.impl;

import com.example.common.PageResult;
import com.example.dto.WSCheckDto;
import com.example.entity.WSCheck;
import com.example.mapper.WSCheckMapper;
import com.example.service.WSCheckService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class WSCheckServiceImpl implements WSCheckService {
    @Autowired
    private WSCheckMapper wsCheckMapper;

    @Override
    public PageResult page(WSCheckDto wsCheckDto) {
        PageHelper.startPage(wsCheckDto.getPageNum(), wsCheckDto.getPageSize());
        Page<WSCheck> page = wsCheckMapper.getByDno(wsCheckDto);
        return new PageResult(page.getTotal(), page.getResult());
    }

    @Override
    public void add(WSCheck wsCheck) {
        wsCheckMapper.add(wsCheck);
    }

    @Override
    public void deleteByDno(String dno) {
        wsCheckMapper.deleteByDno(dno);
    }

    @Override
    public void update(WSCheck wsCheck) {
        wsCheckMapper.update(wsCheck);
    }
}
